import request from '@/utils/request'

/**
 *
 * @param {data} 入参
 * @abstract 管理员增删改查接口
 */
export function addManagerAjax(data) {
  return request({
    url: '/admin/sysUsers',
    method: 'post',
    data: { ...data }
  })
}

export function updateManagerAjax(data) {
  return request({
    url: '/admin/sysUsers/' + data.id,
    method: 'put',
    data: { ...data }
  })
}

export function fetchManagerAjax(data) {
  return request({
    url: '/admin/sysUsers',
    method: 'get',
    params: { ...data }
  })
}

export function delManagerAjax(data) {
  return request({
    url: '/admin/sysUsers/' + data.id,
    method: 'delete'
  })
}
/**
 *
 * @param {data} 入参
 * @abstract 角色增删改查接口
 */
export function addRoleAjax(data) {
  return request({
    url: '/admin/sysRoles',
    method: 'post',
    data: { ...data }
  })
}

export function updateRoleAjax(data) {
  return request({
    url: '/admin/sysRoles/' + data.id,
    method: 'put',
    data: { ...data }
  })
}

export function fetchRoleAjax(data) {
  return request({
    url: '/admin/sysRoles',
    method: 'get',
    params: { ...data }
  })
}

export function delRoleAjax(data) {
  return request({
    url: '/admin/sysRoles/' + data.id,
    method: 'delete'
  })
}

/**
 *
 * @param {data} 入参
 * @abstract 菜单增删改查接口
 */
export function addMenuAjax(data) {
  return request({
    url: '/admin/sysAccess',
    method: 'post',
    data: { ...data }
  })
}

export function updateMenuAjax(data) {
  return request({
    url: '/admin/sysAccess/' + data.id,
    method: 'put',
    data: { ...data }
  })
}

export function fetchMenuAjax(data) {
  return request({
    url: '/admin/sysAccess',
    method: 'get',
    params: { ...data }
  })
}

export function delMenuAjax(data) {
  return request({
    url: '/admin/sysAccess/' + data.id,
    method: 'delete'
  })
}

/**
 *
 * @param {data} 入参
 * @abstract 菜单增删改查接口
 */

export function addRoleAccessAjax(data) {
  return request({
    url: '/admin/roleAccess',
    method: 'post',
    data: { ...data }
  })
}

export function updateRoleAccessAjax(data) {
  return request({
    url: '/admin/roleAccess/' + data.id,
    method: 'put',
    data: { ...data }
  })
}

export function fetchRoleAccessAjax(data) {
  return request({
    url: '/admin/roleAccess/' + data.roleId,
    method: 'get'
    // params: { ...data }
  })
}

export function delRoleAccessAjax(data) {
  return request({
    url: '/admin/roleAccess/' + data.id,
    method: 'delete'
  })
}
